//导入防抖函数
import { debounce } from '../common/utils'

export const itemListenerMixin = {
  data() {
    return {
      itemImgListener: null,
      refresh: null
    }
  },
  mounted() {
    // const refresh = debounce(this.$refs.scroll.refresh, 200, this)
    this.refresh = debounce(this.$refs.scroll.refresh, 200, this)
    this.itemImgListener = () => {
      this.refresh()
    }
    this.$bus.$on('itemImageLoad', this.itemImgListener)
  }
}

export const backTopMixin = {
  data() {
    return {
      isShow: false
    }
  },
  methods: {
    //点返回顶部事件
    backClick() {
      this.$refs.scroll.scrollTo(0, 0, 500) //500毫秒 回到顶部
    }
  },
}
